home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / showpartial < prev    next >
Text File  |  1995-07-02  |  3KB  |  140 lines

  1. :
  2. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  3. # Permission to use, copy, modify, and distribute this material 
  4. # for any purpose and without fee is hereby granted, provided 
  5. # that the above copyright notice and this permission notice 
  6. # appear in all copies, and that the name of Bellcore not be 
  7. # used in advertising or publicity pertaining to this 
  8. # material without the specific, prior written permission 
  9. # of an authorized representative of Bellcore.  BELLCORE 
  10. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  11. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  12. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  13.  
  14. # Conversion from C shell to Bourne shell by Z-Code Software Corp.
  15. # Conversion Copyright (c) 1992 Z-Code Software Corp.
  16. # Permission to use, copy, modify, and distribute this material
  17. # for any purpose and without fee is hereby granted, provided
  18. # that the above copyright notice and this permission notice
  19. # appear in all copies, and that the name of Z-Code Software not
  20. # be used in advertising or publicity pertaining to this
  21. # material without the specific, prior written permission
  22. # of an authorized representative of Z-Code.  Z-CODE SOFTWARE
  23. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
  24. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS",
  25. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  26.  
  27. if [ -z "$METAMAIL_TMPDIR" ]
  28. then
  29.     METAMAIL_TMPDIR=/tmp
  30. fi
  31.  
  32. TREEROOT=$METAMAIL_TMPDIR/msg-parts-`whoami`
  33.  
  34. if test -z "$3" -o ! -z "$5"
  35. then
  36.     echo "Usage: showpartial file id partnum totalnum"
  37.     exit 1
  38. fi
  39.  
  40. file=$1
  41.  
  42. # This next line is because message-id can contain weird chars
  43. id=`echo $2 | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\ `
  44.  
  45. partnum=$3
  46.  
  47. if test -z "$4"
  48. then
  49.     totalnum=-1
  50. else
  51.     totalnum=$4
  52. fi
  53.  
  54. if test ! -d $TREEROOT
  55. then
  56.     mkdir $TREEROOT
  57.     if test $? -ne 0
  58.     then
  59.         echo mkdir $TREEROOT failed
  60.         exit 1
  61.     fi
  62. fi
  63.  
  64. if test ! -d ${TREEROOT}/$id
  65. then
  66.     mkdir ${TREEROOT}/$id
  67.     if test $? -ne 0
  68.     then
  69.             echo mkdir ${TREEROOT}/$id failed
  70.         exit 1
  71.     fi
  72. fi
  73.  
  74. cp $file ${TREEROOT}/$id/$partnum
  75. if test $? -ne 0
  76. then
  77.     echo cp $file ${TREEROOT}/$id/$partnum failed
  78.     exit 1
  79. fi
  80.  
  81. if test $totalnum -eq -1
  82. then
  83.     if test -r ${TREEROOT}/$id/CT
  84.     then
  85.         totalnum=`cat ${TREEROOT}/$id/CT`
  86.     else
  87.             totalnum=-1
  88.     fi
  89. else
  90.     echo $totalnum > ${TREEROOT}/$id/CT
  91. fi
  92.  
  93. # Slightly bogus here -- the shell messes up the newlines in the headers
  94. # if ($partnum == 1) then
  95. #     echo $MM_HEADERS > ${TREEROOT}/$id/HDRS
  96. # endif
  97. found=0
  98. ix=1
  99. list=""
  100. limit=$totalnum
  101. if test $limit -eq -1
  102. then
  103.     limit=25
  104. fi
  105.  
  106. while test "$ix" -le "$limit"
  107. do
  108.     if test -f ${TREEROOT}/$id/$ix
  109.     then
  110.         list="$list $ix"
  111.         found=`expr $found + 1`
  112.     fi
  113.     ix=`expr $ix + 1`
  114. done
  115.  
  116. if test "$found" = "$totalnum"
  117. then
  118.     cd ${TREEROOT}/$id
  119.     cat $list > ${TREEROOT}/$id/FULL
  120.     rm $list
  121.     echo All parts of this ${totalnum}-part message have now been read.
  122.     metamail -d  ${TREEROOT}/$id/FULL
  123.     echo WARNING:  To save space, the full file is now being deleted.  
  124.     echo You will have to read all $totalnum parts again to see the full message again.
  125.     rm ${TREEROOT}/$id/FULL
  126.     rm ${TREEROOT}/$id/CT
  127.     cd ${METAMAIL_TMPDIR}
  128.     rmdir ${TREEROOT}/$id
  129.     rmdir ${TREEROOT} > /dev/null 2>&1
  130. else
  131.     if test "$totalnum" -eq -1
  132.     then
  133.         echo So far you have only read $found of the several parts of this message.
  134.     else
  135.         echo So far you have only read $found of the $totalnum parts of this message.
  136.     fi
  137.     echo When you have read them all, then you will see the message in full.
  138. fi
  139.